package com.pl.service.impl;  

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pl.bean.ManagePageBean;
import com.pl.dao.ManagePageBeanDao;
import com.pl.service.ManagePageService;

import javax.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 
 */
@Service("managePageService")
public class ManagePageServiceImpl implements ManagePageService{

	private static Logger log = LogManager.getLogger();

	@Resource(name="managePageBeanDao")
	private ManagePageBeanDao managePageBeanDao;

	/**
	 * 新增
	 */
	@Transactional
	public void addManagePage(ManagePageBean managePageBean){
		
		managePageBeanDao.addManagePageBean(managePageBean);
	}

	/**
	 * 修改
	 */
	@Transactional
	public void updateManagePage(ManagePageBean managePageBean){
		
		managePageBeanDao.updateManagePageBean(managePageBean);
	}
	
	/**
	 * 根据条件获得数量
	 */
	public int getManagePageNum(ManagePageBean managePageBean){
		
		return managePageBeanDao.getManagePageBeanNum(managePageBean);
	}
	
	/**
	 * 根据条件获得数据
	 */
	public List<ManagePageBean> getManagePage(ManagePageBean managePageBean){
		
		return managePageBeanDao.getManagePageBean(managePageBean);
	}
	
	/**
	 * 根据用户获得页面
	 */
	public List<ManagePageBean> getManagePageByUser(long userId, String clientId){
		
		ManagePageBean bean = new ManagePageBean();
		bean.setUser_id(userId);
		bean.setClientId(clientId);
		
		return managePageBeanDao.getManagePageBean(bean);
	}
	
	/**
	 * 根据条件获得数据
	 */
	public ManagePageBean getManagePageById(Long id){
		
		ManagePageBean managePageBean = new ManagePageBean();
		managePageBean.setId(id);
		
		List<ManagePageBean> list = getManagePage(managePageBean);
		if(list !=null && !list.isEmpty()){
    		return list.get(0);
    	}
    	
    	return null;
	}
}
